package org.xsk.algorithm.sort;

/**
 * 比较次数： < n^2/2
 * 交换次数： < n
 * 
 */
public class InsertSort {
    
    public void insertSort(int[] args){
        int in,out;

        for (out = 1; out < args.length; out++) {
            int temp = args[out];
            in = out;
            while (in > 0 && args[in -1] >= temp) {
                args[in] = args[in -1];
                --in;
            }
            args[in] = temp;
        }    

    }
    
}
